﻿using System;
using System.ComponentModel;
using System.Web.UI;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.Core;

namespace Yuanlin.Business
{
    public class ParentArticleCategories : YuanlinUserControl,
        IReplyConverter<NewsCategoryReply, GetListOperation>
    {
        protected Repeater list;
        private EntityList newsCategorys;

        public override void GetRequests(List<BaseRequestBinder> requestBinders)
        {
            if (!IsPostBack)
            {
                NewsCategoryListRequest request = new NewsCategoryListRequest();
                request.UpNewsCategoryId = 0;
                request.PageIndex = 0;
                request.PageSize = int.MaxValue;
                requestBinders.Add(RequestHelper.BuildGetNewsCategoryListRequest(this, request));
            }
        }

        private void BindData()
        {
            list.DataSource = newsCategorys;
            list.DataBind();
        }

        #region IReplyConverter<NewsCategoryReply,GetListOperation> Members

        public void ConvertReply(NewsCategoryReply reply, GetListOperation operation)
        {
            if (reply != null)
            {
                newsCategorys = reply.EntityList;

                if (!IsPostBack)
                {
                    BindData();
                }
            }
        }

        #endregion
    }
}
